package us.icitap.cm.utils;

import us.icitap.cm.business.entities.BaseEntity;

import com.vaadin.ui.Component;
import com.vaadin.ui.DateField;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;

public class UIUtils {

	
	public static FormLayout genFormLayoutContainer(Component c){
		FormLayout fl = new FormLayout();
		fl.addComponent(c);
		return fl;
	}
	
	public static HorizontalLayout genIntervalDatesContainer(DateField d1, DateField d2){
		HorizontalLayout hl = new HorizontalLayout();
		
		FormLayout fl1 = new FormLayout();
		fl1.setMargin(false);
		fl1.addComponent(d1);
		
		FormLayout fl2 = new FormLayout();
		fl2.setMargin(false);
		fl2.addComponent(d2);
		
		hl.addComponent(fl1);
		hl.addComponent(fl2);
		
		return hl;
	}
	
	public static String textConverter(BaseEntity entity){
		if(entity == null) return "-";
		return entity.getTag();
	}
	
	public static String textConverter(Object obj){
		if(obj == null) return "-";
		return obj.toString();
	}
}
